package cn.itcast.nems.base.web.controller.o;

import cn.itcast.ic.common.bean.Page;
import cn.itcast.nems.common.PageQueryModel;
import cn.itcast.nems.common.web.vo.BasePageRequest;
import cn.itcast.nems.product.api.ProductApi;
import cn.itcast.nems.product.dto.ProductClazzDTO;
import cn.itcast.nems.product.dto.ProductClazzQueryDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Objects;

/**
 * <p>
 * 获取执行价格
 * </p>
 *
 * @author zhouwei
 * @since 2023/9/10 3:53 PM
 **/
@RestController
@RequestMapping("/o/product")
public class EnrolProductController {
    @Autowired
    private ProductApi productApi ;

    /**
     * 产品-班级列表分页查询
     * @param queryParam 请求参数
     * @return 分页结果
     */
    @PostMapping("/clazz/page/list")
    public ResponseEntity<?> findClazzPageList (@RequestBody BasePageRequest<ProductClazzQueryDTO> queryParam){
        queryParam.convert();
        ProductClazzQueryDTO clazzQueryDTO = Objects.nonNull(queryParam.getCondition())? queryParam.getCondition(): new ProductClazzQueryDTO() ;
        PageQueryModel<ProductClazzQueryDTO> queryModel =new PageQueryModel<>(queryParam.getPageNumber(),queryParam.getPageSize(),clazzQueryDTO) ;
        Page<ProductClazzDTO> page  = productApi.findClazzPageList(queryModel) ;
        return ResponseEntity.ok().body(page) ;
    }
}
